/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2013.11.19                                          *
 *                                                                       *
 *************************************************************************/

#ifndef FreeMAPs_include_COMMON_mesh_NodeGroup_h
#define FreeMAPs_include_COMMON_mesh_NodeGroup_h

#include "FreeMAPsConfig.h"

//C++ headers
#include <string>
#include <map>

//FreeMAPs headers
#include "COMMON/base/Common.h"

namespace FreeMAPs
{

/**
 * @brief NodeGroup used to save all the groups contains nodes.
 *
 * this is mainly used as the boundary.
 */
class NodeGroup
{
public:

    NodeGroup();

    explicit
    NodeGroup(
        const std::string& group_name);

    ~NodeGroup();

public:

    inline const std::string&
    get_group_name() const;

    inline const std::set<int>&
    get_nodes()const;

    inline void
    insert_node (
        const int node);

    inline bool
    is_empty()const;

public:

    void
    clear();

    /**
     * renumber all nodes using it's new id.
     * the node_id_map<old_node_id, new_node_id>
     */
    void
    renumber_nodes (
        const std::map<int, int>& node_id_map);

    friend std::ostream&
    operator << (
        std::ostream& os,
        const NodeGroup& rhs);

private:

    std::string d_group_name;

    /*
     * set<node_id>
     */
    std::set<int> d_nodes;
};

}

#include "COMMON/mesh/NodeGroup.inl"

#endif
